//
//  PurchasePowerListCell.swift
//  SCA
//
//  Created by tjun on 2025/9/12.
//

import UIKit
 


class PurchasePowerListCell: BaseTableViewCell {

    private let infoView = PurchasePowerListInfoView()
    private let descriptionLabel = UILabel()
    private let iconPlusView = IconPlusView()
    private let containerView = UIView()

    var data: PurchasePowerListData? {
        didSet {
            guard let data = data else { return }
            descriptionLabel.attributedText = data.attributedText
            infoView.model = data.model
            iconPlusView.configure(with: data.model.icons)
        }
    }
    
    override func setSubView() {
        super.setSubView()
        
        selectionStyle = .none
        
        backgroundColor = AppStyle.color.background
        contentView.addSubview(containerView)
        containerView.addCorner(radius: 10)
        containerView.backgroundColor = UIColor.black
        containerView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(AppStyle.margin.left)
            make.top.equalToSuperview()
            make.bottom.equalTo(-AppStyle.margin.left)
        }

        descriptionLabel.numberOfLines = 0
        containerView.addSubview(infoView)
        containerView.addSubview(descriptionLabel)
        containerView.addSubview(iconPlusView)

    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        guard let data = data else { return }
        
        infoView.frame = data.infoViewRect
        descriptionLabel.frame = data.descriptionRect
        iconPlusView.frame = data.iconsRect
    }

    
}
